{% extends 'bootstrap-modal-layout.html.twig' %}

{% block title %}
  {{ dict_text('questionType', analysis.questionMarker.type) }}
{% endblock %}

{% set modal_class = 'mark-questions-modal topic-player-statistical' %}

{% do script(['libs/echarts.js', 'app/js/course-manage/question-marker/modal/index.js']) %}

{% block body %}
  {% set question = analysis.questionMarker %}
  {% set stats = analysis.metaStats %}

  <ul class="popup-topic" data-type={{ question.type }}>
    <li class="title">
      {% if question.type == 'fill' %}
        {{ question.stem|fill_question_stem_html|bbCode2Html|raw }}
      {% else %}
        {{ question.stem|bbCode2Html|raw }}
      {% endif %}
    </li>

    {% if question.type == 'fill' %}
      {% for index,subAnswer in question.answer %}
        <li class="list clearfix ">
          <span class="num">{{ loop.index }}</span>
          {{ 'question.correct_answer_tips'|trans }}<strong class="text-success">{{ subAnswer|join('site.default.or'|trans) }}</strong>
          <span class="pull-right">{{ 'question.correct_rate'|trans }}：<span class="badge badge-primary">{{ stats[loop.index0].pct }}%</span></span></li>
      {% endfor %}

    {% elseif question.type == 'determine' %}
      <li class="list {% if question.answer[0] == 1 %} right {% endif %}">
        <span class="num">A</span>
        <div class="info">{{ 'question.answer_correct'|trans }}</div>
        <span class="pull-right">{{ 'question.selection_rate'|trans }}：<span class="badge">{{ stats[0].pct }}%</span>
      </li>
      <li class="list {% if question.answer[0] == 0 %} right {% endif %}">
        <span class="num">B</span>
        <div class="info">{{ 'question.answer_wrong'|trans }}</div>
        <span class="pull-right">{{ 'question.selection_rate'|trans }}：<span class="badge">{{ stats[1].pct }}%</span>
      </li>
    {% else %}
      {% for subAnswer in question.metas.choices %}
        {% set choice = question.metas.choices[loop.index0] %}
        <li class="list clearfix {% if loop.index0 in question.answer %} right {% endif %}">
          <span class="num" >{{ (loop.index0+65)|chr }}</span>
          <div  class="info">{{  choice|bbCode2Html|raw }}</div>
          <span class="pull-right">{{ 'question.selection_rate'|trans }}：<span class="badge">{{ stats[loop.index0].pct }}%</span>
        </li>
      {% endfor %}
    {% endif %}
  </ul>
  <ul class="popup-topic topic-resolve">
    <div class="list">
      <div class="tab-content">
        <div id="figure" class="tab-pane active" data-stats="{{ analysis.metaStats|json_encode }}">
          <div id="main" style="height:230px;"></div>
        </div>
      </div>
    </div>
  </ul>
{% endblock %}

{% block footer %}
  <button type="button" class="btn btn-primary" data-dismiss="modal">{{ 'form.btn.close'|trans }}</button>
{% endblock %}